package com.zld.smarket.controller;


import com.zld.smarket.pojo.Goods;
import com.zld.smarket.pojo.GoodsType;
import com.zld.smarket.pojo.Supplier;
import com.zld.smarket.result.ExceptionMsg;
import com.zld.smarket.result.ResponseData;
import com.zld.smarket.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/supplier")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ResponseData findList(Integer page, Integer limit) {
        return supplierService.findList(page, limit);
    }

    @RequestMapping(value = "/del")
    public ResponseData delete(Long[] ids){
        Integer integer = supplierService.deleteById(ids);
        return new ResponseData(ExceptionMsg.SUCCESS);
    }
    @RequestMapping(value = "/search",method = RequestMethod.GET)
    public ResponseData search(String s,Integer page, Integer limit){
        return  supplierService.search(s,page,limit);
    }

    @RequestMapping(value = "/add")
    public ResponseData add(Supplier supplier) {

            Integer integer = supplierService.addSupplier(supplier);
            return new ResponseData(ExceptionMsg.SUCCESS);

    }

    @RequestMapping(value = "/update")
    public ResponseData updateById(Supplier supplier){
        return supplierService.updateById(supplier);
    }

    @RequestMapping("/getName")
    public List<Supplier> getName() {
        return supplierService.selectAll();
    }
}
